package com.txf.coomon.mvp.net_okhttp.presenter;

import android.content.Context;

import com.google.gson.JsonElement;
import com.txf.coomon.net.net_okhttp.listener.HttpJsonListener;
import com.txf.coomon.mvp.net_okhttp.contract.DemoContract;
import com.txf.coomon.mvp.net_okhttp.model.DemoModel;

import java.util.HashMap;


/**
 * @author txf
 * @create 2019/1/22 0022
 * @
 */

public class DemoPresenter extends DemoContract.Presenter {

    private Context mContext;
    private DemoModel model;

    public DemoPresenter(Context mContext) {
        model = new DemoModel();
        this.mContext = mContext;
    }

    @Override
    public void getData(Context context, int tag, HashMap<String, Object> maps) {
        model.getData(context, tag, maps, new HttpJsonListener() {
            @Override
            public void onSuccess(int tag, JsonElement data, String message) {
                super.onSuccess(tag, data, message);
                getView().httpOnSuccess(tag, data, message);
            }

            @Override
            public void onError(int tag, int error, String message) {
                super.onError(tag, error, message);
                getView().httpOnError(tag, error, message);
            }
        });
    }
}
